%% term_Uold_grad_Uold_V
function vector_b = term_Uold_grad_Uold_V(mesh, fespace, Uold)
Nb1 = fespace.Nb;
Nlb1 = fespace.Nlb;
rows = zeros(Nb1,1);
val1 = rows;
val2 = rows;
flag = 1;
for n = 1:mesh.Ne
    V = mesh.node(mesh.elem(n,:),:);
    [int_points_loc, int_weights_loc] = integral_loc(V, "2d");
    phi = basis_loc(V, int_points_loc(:,1), int_points_loc(:,2), fespace.basis_type, "x");
    phix = basis_loc(V, int_points_loc(:,1), int_points_loc(:,2), fespace.basis_type, "dx");
    phiy = basis_loc(V, int_points_loc(:,1), int_points_loc(:,2), fespace.basis_type, "dy");
    u1 = phi * Uold(fespace.elem(n,:));
    u1x = phix * Uold(fespace.elem(n,:));
    u1y = phiy * Uold(fespace.elem(n,:));
    u2 = phi * Uold(fespace.elem(n,:)+Nb1);
    u2x = phix * Uold(fespace.elem(n,:)+Nb1);
    u2y = phiy * Uold(fespace.elem(n,:)+Nb1);
    for i = 1:Nlb1
        f1 = u1 .* u1x .* phi(:,i) + u2 .* u1y .* phi(:,i);
        f2 = u1 .* u2x .* phi(:,i) + u2 .* u2y .* phi(:,i);
        r1 = int_weights_loc * f1;
        r2 = int_weights_loc * f2;
        rows(flag) = fespace.elem(n,i);
        val1(flag) = r1;
        val2(flag) = r2;
        flag = flag + 1;
    end
end
b1 = sparse(rows, 1, val1, Nb1, 1);
b2 = sparse(rows, 1, val2, Nb1, 1);
vector_b = [b1; b2];
end